package com.yunyao.dao.service.bamu.impl;

import com.yunyao.common.dto.PaymentHistoryDto;
import com.yunyao.common.web.util.PageResult;
import com.yunyao.dao.model.BamuPaymentHistory;
import com.yunyao.dao.mapper.BamuPaymentHistoryMapper;
import com.yunyao.dao.service.bamu.IBamuPaymentHistoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * <p>
 * 合同收款记录 服务实现类
 * </p>
 *
 * @author xingjishuai
 * @since 2024-07-02
 */
@Service
public class BamuPaymentHistoryServiceImpl extends ServiceImpl<BamuPaymentHistoryMapper, BamuPaymentHistory> implements IBamuPaymentHistoryService {


    @Override
    public PageResult<BamuPaymentHistory> pageList(@Valid @NotNull PaymentHistoryDto dto){
        List<BamuPaymentHistory> list = lambdaQuery()
                .eq(BamuPaymentHistory::getContractId, dto.getContractId())
                .eq(BamuPaymentHistory::getIsDeleted, 0)
                .list();
        if(CollectionUtils.isEmpty(list))
            return new PageResult<>();
        return new PageResult<>(list, dto.getPageIndex(), dto.getPageSize());
    }

}
